package com.tbit.uqbike.object.pojo.dto;

import com.tbit.utils.Assert;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;

/**
 * @Author:BUGTian
 * @DATE: 2022/11/12
 */
@Data
public class BaseLogQueryPageDTO implements Serializable {
    /**
     * 品牌id
     */
    @NotNull
    private Integer brandId;
    /**
     * 区域id 多个用,隔开
     */
    @NotNull
    private String accountIds;
    /**
     * 开始时间
     */
    @NotNull
    private Date startTime;
    /**
     * 结束时间
     */
    @NotNull
    private Date endTime;
    /**
     * 当前页码
     */
    @NotNull
    private Integer page;
    /**
     * 每页显示的行数
     */
    @NotNull
    private Integer size;

    public void assertParam() {
        Assert.notNulls("参数有误", brandId, accountIds, startTime, endTime, page, size);
    }

    public void assertParamIgnorePage() {
        Assert.notNulls("参数有误", brandId, accountIds, startTime, endTime);
    }

    /**
     * 获取区域idList
     *
     * @return
     */
    public List<Integer> getAccountIdList() {
        List<Integer> list = new LinkedList<>();
        for (String s : accountIds.split(",")) {
            list.add(Integer.parseInt(s));
        }
        return list;
    }
}
